<?php

/**
 * @Author: ddyake
 * @Date:   2020-12-09 16:39:35
 * @Last Modified by:   ddyake
 * @Last Modified time: 2020-12-25 00:14:04
 * 根据authCode 获取用户在支付宝的唯一userid，查询user表是否存在，然后返回用户，
 * 没有则返回失败，由用户手动点击获取
 */
// require_once $this->website['path']['root'].'/vendor/autoload.php';
// use Alipay\EasySDK\Kernel\Factory;
// use Alipay\EasySDK\Kernel\Util\ResponseChecker;
// use Alipay\EasySDK\Kernel\Config;

$json = array('status'=>'error','msg'=>'error','data'=>'');

$sys = $this->website['class']['unity']
       ->configura('sys');

$params = $this->params();
 
$json['data'] = $params['authCode'];

// $aop = new AopClient ();
// Factory::setOptions($this->website['class']['']->zfbgGetOptions());
// $result = Factory::payment()
// $responseChecker = new ResponseChecker();
// if ($responseChecker->success($result)) {
//   $json['msg'] = "调用成功";
// } else {
//   $json['调用失败，原因：'. $result->msg."，".$result->subMsg];
// }

 
// if(!empty($resultCode)&&$resultCode != 10000){
//   $json['msg'] = '系统繁忙';
// } else {

//   // $result->$responseNode
//   // {
//   //     "user_id": "2088102150477652",
//   //     "access_token": "20120823ac6ffaa4d2d84e7384bf983531473993",
//   //     "expires_in": "3600",
//   //     "refresh_token": "20120823ac6ffdsdf2d84e7384bf983531473993",
//   //     "re_expires_in": "3600"
//   // }

//   $user = $this->website['class']['db']
//                ->table('user')
//                ->field('id','zfbUser')
//                ->where('zfbUserId=?',$result->$responseNode->user_id)
//                ->one();
//   if(!($user['id']??false)){
//     $json['msg'] = 'login';//数据库未找到用户-需要手动登录
//   }else{
//     $json['msg'] = 'ok';
//     $json['status']='ok';
//     $token = md5($user['id'].$result->$responseNode->user_id.$this->website['safe']['key']).$user['id'];
//     $json['data'] = array(
//       'token'=>$token,
//       'user'=>$user['zfbUser']
//     );

//   }

// }

$this->json_encode($json);